#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main()
{
	int n, m;
	int i=0, j=0,x=0;
	int arra[1000];
	int arrb[1000];
	int arr[1000];
	n = 0, m = 0;
	while (scanf("%d%d", &n, &m) != EOF)
	{
		for (i = 0; i < n; i++)
		{
			scanf("%d", &arra[i]);
		}
		for (j = 0; j < m; j++)
		{
			scanf("%d", &arrb[j]);
		}
		i = 0, j = 0;
		for (x = 0; x < n + m; x++)
		{
			if (i < n && j < m)
			{
				if (arra[i] < arrb[j])
				{
					arr[x] = arra[i];
					i++;
				}
				else
				{
					arr[x] = arrb[j];
					j++;

				}
			}
			else if (i < n && j >= m)
			{
				arr[x] = arra[i];
				i++;

			}

			else if (i >= n && j < m)
			{
				arr[x] = arrb[j];
				j++;

			}
		}

		for (x = 0; x < n + m; x++)
		{
			printf("%d ", arr[x]);

		}





	}






	return 0;
}